package com.woniuxy.controller;

import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.entity.TestTestBank;
import com.woniuxy.service.TestTestBankService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * (TestTestBank)表控制层
 *
 * @author zjx
 * @since 2021-05-14 19:42:04
 */
@RestController
@RequestMapping("testTestBank")
public class TestTestBankController {
    /**
     * 服务对象
     */
    @Resource
    private TestTestBankService testTestBankService;

    @ApiOperation("通过testId和testBankId删除一条数据")
    @DeleteMapping("deleteOne/{testId}/{testBankId}")
    public ResponseEntity deleteOne(@ApiParam("试题id")@PathVariable()Integer testId,
                                    @ApiParam("题库id")@PathVariable()Integer testBankId){
//        System.out.println("testId="+testId+":testBankId"+testBankId);
        int row = this.testTestBankService.deleteOne(testId,testBankId);
        return new ResponseEntity(200,"OK",row);
    }

    @ApiOperation("存储testId和testBankId")
    @PostMapping("insertTestTestBanks")
    public ResponseEntity insertTestTestBanks(@ApiParam("题库id")@RequestBody Map<String,Object> map){
//        System.out.println("testBankId=="+map);

        int row = this.testTestBankService.insertTestTestBanks(map);
        return new ResponseEntity(200,"OK",row);
    }
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public TestTestBank selectOne(int id) {
        return this.testTestBankService.queryById(id);
    }

}
